<!--  -->
<template>
  <div class="main-class-body-items" @click="goToClassDetail()">
    <div class="main-class-body-items-left">
      <img :src="item.thumb" alt="" />
    </div>
    <div class="main-class-body-items-right">
      <div class="main-class-body-items-right-title">{{ item.title }}</div>
      <div class="main-class-body-items-right-info">
        <div class="main-class-body-items-right-info-sub">{{ item.user_count }}人已订阅</div>
        <div class="main-class-body-items-right-info-charge">
          <div v-if="item.is_free == 1" class="free-text">免费</div>
          <div v-else class="main-class-body-items-right-info-charge-text">
            <span class="unit">￥</span>
            {{ item.charge }}
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
//这里可以导入其他文件（比如：组件，工具js，第三方插件js，json文件，图片文件等等）
//例如：import 《组件名称》 from '《组件路径》';

export default {
  //import引入的组件需要注入到对象中才能使用
  props: ["item"],
  components: {},
  data() {
    //这里存放数据
    return {};
  },
  //监听属性 类似于data概念
  computed: {},
  //监控data中的数据变化
  watch: {},
  //方法集合
  methods: {
    goToClassDetail(item) {
      this.$router.push({
        path: "/vod/detail",
        query: {
          id: this.item.id,
        },
      });
    },
  },
  //生命周期 - 创建完成（可以访问当前this实例）
  created() {},
  //生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {},
  beforeCreate() {}, //生命周期 - 创建之前
  beforeMount() {}, //生命周期 - 挂载之前
  beforeUpdate() {}, //生命周期 - 更新之前
  updated() {}, //生命周期 - 更新之后
  beforeDestroy() {}, //生命周期 - 销毁之前
  destroyed() {}, //生命周期 - 销毁完成
  activated() {}, //如果页面有keep-alive缓存功能，这个函数会触发
};
</script>
<style lang="less" scoped>
.main-class-body-items {
  width: 100%;
  display: flex;
  margin-bottom: 15px;
  .main-class-body-items-left {
    width: 120px;
    height: 90px;
    margin-right: 10px;
    img {
      width: 120px;
      height: 90px;
      border-radius: 4px;
    }
  }

  .main-class-body-items-right {
    flex: 1;
    padding-top: 5px;
    .main-class-body-items-right-title {
      width: 100%;
      height: 40px;
      float: left;
      font-size: 15px;
      font-weight: 500;
      color: #171923;
      line-height: 20px;
      overflow: hidden;
      text-overflow: ellipsis;
      -webkit-line-clamp: 2;
      -webkit-box-orient: vertical;
      margin-bottom: 15px;
    }

    .main-class-body-items-right-info {
      width: 100%;
      height: auto;
      float: left;
      display: flex;
      align-items: center;
      .main-class-body-items-right-info-sub {
        flex: 1;
        text-align: left;
        font-size: 12px;
        font-weight: 400;
        color: #999;
        line-height: 12px;
      }

      .main-class-body-items-right-info-charge {
        flex: 1;
        text-align: right;
        font-size: 18px;
        line-height: 18px;
        font-weight: 600;
        .free-text {
          font-size: 14px;
          font-weight: 600;
          color: #52c41a;
        }
        .main-class-body-items-right-info-charge-text {
          color: #ff5858;
          .unit {
            color: #ff5858;
          }
        }
      }
    }
  }
}
</style>
